package uaiContacts.model;
import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Droog
 */
@Entity
@Table(name = "tb_uf", catalog = "sistema_ipi", schema = "public")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Uf.findAll", query = "SELECT u FROM Uf u"),
    @NamedQuery(name = "Uf.findBySgUf", query = "SELECT u FROM Uf u WHERE u.sgUf = :sgUf"),
    @NamedQuery(name = "Uf.findByNomUf", query = "SELECT u FROM Uf u WHERE u.nomUf = :nomUf")})
public class Uf implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 2)
    @Column(name = "sg_uf", nullable = false, length = 2)
    private String sgUf;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 40)
    @Column(name = "nom_uf", nullable = false, length = 40)
    private String nomUf;
    @JoinColumn(name = "id_pais", referencedColumnName = "id_pais", nullable = false)
    @ManyToOne(optional = false)
    private Pais idPais;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "sgUf")
    private List<Cidade> cidadeList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "sgUf")
    private List<Endereco> enderecoList;

    public Uf() {
    }

    public Uf(String sgUf) {
        this.sgUf = sgUf;
    }

    public Uf(String sgUf, String nomUf) {
        this.sgUf = sgUf;
        this.nomUf = nomUf;
    }

    public String getSgUf() {
        return sgUf;
    }

    public void setSgUf(String sgUf) {
        this.sgUf = sgUf;
    }

    public String getNomUf() {
        return nomUf;
    }

    public void setNomUf(String nomUf) {
        this.nomUf = nomUf;
    }

    public Pais getIdPais() {
        return idPais;
    }

    public void setIdPais(Pais idPais) {
        this.idPais = idPais;
    }

    @XmlTransient
    public List<Cidade> getCidadeList() {
        return cidadeList;
    }

    public void setCidadeList(List<Cidade> cidadeList) {
        this.cidadeList = cidadeList;
    }

    @XmlTransient
    public List<Endereco> getEnderecoList() {
        return enderecoList;
    }

    public void setEnderecoList(List<Endereco> enderecoList) {
        this.enderecoList = enderecoList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (sgUf != null ? sgUf.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Uf)) {
            return false;
        }
        Uf other = (Uf) object;
        if ((this.sgUf == null && other.sgUf != null) || (this.sgUf != null && !this.sgUf.equals(other.sgUf))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "model.Uf[ sgUf=" + sgUf + " ]";
    }
    
}